/**
 * 广告计划相关api
 */
angular.module('imsApp').factory('CampaignsManager', ['$http','api', 'paramsManager', function ($http,api, paramsManager) {
    var CampaignsManager = {
        /**
         * 获取广告计划列表
         params:[pageNo,pageSize]//顺序不能错
         query :{keyword:xxx}
         */
        campaignsList: function (params, query) {
            return $http.get(api+'/ims/campaigns/' + paramsManager.params(params) + paramsManager.query(query)).then(function (result) {
                return result;
            });
        },
        /**
         *广告计划添加
         * @param params
         * @returns {"c":"s","campaignId":1}?{"c":"f", "i":"添加失败"}
         */
        campaignsAdd: function (params) {
            return $http.post(api+'/ims/campaigns', params).then(function (result) {
                return result;
            });
        },
        /**
         *广告计划详情
         * @param campaignId
         * @returns {"c":"s","campaignId":1}
         */
        campaignsDetail: function (campaignId) {
            return $http.get(api+'/ims/campaigns/'+campaignId).then(function (result) {
                return result;
            });
        },
        /**
         *补充基础计划信息
         * @param params
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        campaignsEdit: function (campaignId,params) {
            return $http.put(api+'/ims/campaigns/baseinfo/'+campaignId,params).then(function (result) {
                return result;
            });
        },
        /**
         *广告计划修改
         * @param params
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        campaignsEditAgain: function (campaignId,params) {
            return $http.put(api+'/ims/campaigns/detail/'+campaignId,params).then(function (result) {
                return result;
            });
        },
        /**
         *广告计划状态修改
         * @param params campaignId,{status:11}
         * @returns {"c":"f"} ?{"c": "f","i":"修改失败"}
         */
        campaignsStatusEdit: function (campaignId,params) {
            return $http.put(api+'/ims/campaigns/'+campaignId+'/status',params).then(function (result) {
                return result;
            });
        },
        /**
         *广告计划统计
         * @param params [campaignId,pageNo,pageSize],{timeType:timeType}
         */
        campaignsStatistics: function (params,time) {
            return $http.get(api+'/ims/campaignStats/'+paramsManager.params(params)+paramsManager.query(time)).then(function (result) {
                return result;
            });
        }

    };


    return CampaignsManager;
}]);
